home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
cgazv5n4.arc
/
STRNGPTR.H
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-23
|
562b
|
19 lines
//--- STRNGPTR.H ------------------------- Listing 5 -----------
// Hiding a string pointer inside a class
// by Bruce Eckel. See Listing 1 for copyright information.
//--------------------------------------------------------------
#ifndef STRINGPTR_H_
#define STRINGPTR_H_
#include "stringc.h"
class string_ptr {
string * s;
public:
string_ptr() : s(new string("")) {}
string_ptr(char * st) : s(new string(st)) {}
~string_ptr() { delete s; }
string* operator->() { return s; } // This operates unusually
};
#endif // STRINGPTR_H_